﻿using System;
using System.Device.Location;
using System.Reflection;

namespace Mangopollo.Tasks
{
    public class MapsTask
    {
        // Summary:
        //     Gets or sets the location that will be used as the center point for the map.
        //
        // Returns:
        //     Type: System.Device.Location.GeoCoordinate. The center point of the map.
        public GeoCoordinate Center { get; set; }
        //
        // Summary:
        //     Gets or sets the search term that is used to find and tag locations on the
        //     map.
        //
        // Returns:
        //     Type: System.String. The search term used to find and tag locations on the
        //     map.
        public string SearchTerm { get; set; }
        //
        // Summary:
        //     Gets or sets the initial zoom level of the map.
        //
        // Returns:
        //     Type: System.Double. The zoom level of the map.
        public double ZoomLevel { get; set; }


        public void Show()
        {
            Type taskDataType = Type.GetType("Microsoft.Phone.Tasks.MapsTask, Microsoft.Phone");
            object task = taskDataType.GetConstructor(new Type[] {}).Invoke(null);
            Utils.SetProperty(task, "SearchTerm", SearchTerm);
            if (ZoomLevel > 0)
                Utils.SetProperty(task, "ZoomLevel", ZoomLevel);
            Utils.SetProperty(task, "Center", Center);
            MethodInfo showmethod = taskDataType.GetMethod("Show");
            showmethod.Invoke(task, new object[] {});
        }
    }
}